<script type="text/ecmascript-6">
    import { Navbar, DropLoad } from 'vmc';

    import { queryDemoList } from '../../datas/actions/demo';
    import { getDemoList } from '../../datas/getters/demo';

    export default {
        components: {
            Navbar,
            DropLoad
        },
        data() {
            return {
                page: 0,
                hasMore: true
            }
        },
        methods: {
            jump(page, id) {
                this.$router.forward({ name: page, params: { id: id } })
            },
            refresh() {
                this.queryDemoList();
            },
            loadMore() {
                var page = this.page + 1;
                this.queryDemoList(page);
            }
        },
        created() {
            this.$Loading();
            this.queryDemoList();
        },
        events: {
            pageLoaded(success, page) {
                if (success) {
                    this.hasMore = page.current_page < page.total_pages;
                    this.page = page.current_page;
                }
                this.$refs.scroller.done(!success);
            }
        },
        vuex: {
            actions: {
                queryDemoList
            },
            getters: {
                list: getDemoList
            }
        }
    }
</script>